package com.weihui.jxc.common;


import com.weihui.jxc.service.CustomerService;
import com.weihui.jxc.service.GoodsService;
import com.weihui.jxc.service.InportService;
import com.weihui.jxc.service.OperatorService;
import com.weihui.jxc.service.OutportService;
import com.weihui.jxc.service.ProviderService;

/**
 * 实例工厂类
 * @author xiaowei
 *
 */
public class CommonFactory {
	/**
	 * 获取操作员类的实例
	 * 
	 * @return
	 */
	public static OperatorService getOperatorService() {
		try {
			return (OperatorService) Class.forName(Constants.OPERATOR_SERVICE_CLASS).newInstance();
		} catch (Exception e) {
			ErrorManager.printError("CommonFactory getOperatorService()", e);
		}
		return null;
	}

	
	
	/**
	 * 获取CustomerService类的实例
	 * 
	 * @return
	 */
	public static CustomerService getCustomerService() {
		try {
			return (CustomerService) Class.forName(Constants.CUSTOMER_SERVICE_CLASS).newInstance();
		} catch (Exception e) {
			ErrorManager.printError("CommonFactory getCustomerService()", e);
		}
		return null;
	}

	/**
	 * 获取ProviderService类的实例
	 * 
	 * @return
	 */
	public static ProviderService getProviderService() {
		try {
			return (ProviderService) Class.forName(Constants.PROVIDER_SERVICE_CLASS).newInstance();
		} catch (Exception e) {
			ErrorManager.printError("CommonFactory getProviderService()", e);
		}
		return null;
	}

	/**
	 * 获取GoodsService类的实例
	 */
	public static GoodsService getGoodsService() {
		try {
			return (GoodsService) Class.forName(Constants.GOODS_SERVICE_CLASS).newInstance();
		} catch (Exception e) {
			ErrorManager.printError("CommonFactory getGoodsService()", e);
		}
		return null;
	}

	/**
	 * 获取InportService类的实例
	 */
	public static InportService getInportService() {
		try {
			return (InportService) Class.forName(Constants.INPORT_SERVICE_CLASS).newInstance();
		} catch (Exception e) {
			ErrorManager.printError("CommonFactory getInportService()", e);
		}
		return null;
	}
	/**
	 * 获取InportService类的实例
	 */
	public static OutportService getOutportService() {
		try {
			return (OutportService) Class.forName(Constants.OUTPORT_SERVICE_CLASS).newInstance();
		} catch (Exception e) {
			ErrorManager.printError("CommonFactory getInportService()", e);
		}
		return null;
	}
}